<?php

/**
 * This is the model class for table "company".
 *
 * The followings are the available columns in table 'company':
 * @property integer $id
 * @property string $kaisha_mei
 * @property string $logo_img
 * @property string $name_kana
 * @property string $name_roman
 * @property string $gaiyou
 * @property string $address
 * @property string $working
 * @property string $type
 */
class Company extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Company the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'company';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('kaisha_mei, name_kana, name_roman, address', 'required'),
			array('kaisha_mei, address, type', 'length', 'max'=>100),
			array('logo_img, name_kana, name_roman', 'length', 'max'=>50),
			array('gaiyou, working', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, kaisha_mei, logo_img, name_kana, name_roman, gaiyou, address, working, type', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'kaisha_mei' => 'Kaisha Mei',
			'logo_img' => 'Logo Img',
			'name_kana' => 'Name Kana',
			'name_roman' => 'Name Roman',
			'gaiyou' => 'Gaiyou',
			'address' => 'Address',
			'working' => 'Working',
			'type' => 'Type',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('kaisha_mei',$this->kaisha_mei,true);
		$criteria->compare('logo_img',$this->logo_img,true);
		$criteria->compare('name_kana',$this->name_kana,true);
		$criteria->compare('name_roman',$this->name_roman,true);
		$criteria->compare('gaiyou',$this->gaiyou,true);
		$criteria->compare('address',$this->address,true);
		$criteria->compare('working',$this->working,true);
		$criteria->compare('type',$this->type,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}